import os


def filter_data(accurate:bool = False):
    with open("word_and_vector.csv","r",encoding="utf-8") as reader_file:
        the_list = eval( reader_file.read() )
    print(the_list)
    new_list = []

    if accurate:
        for data in the_list:
            if len(data[0]) == 1:
                new_list.append(data[0][0] + "丁真")

    else:
        for data in the_list :
            if len(data[0]) == 1 :
                new_list.append(data[0][0]+"丁真")
            else:
                new_list.append(data[0][0] + data[0][1] + "丁真")
    print(new_list)
    print(len(new_list))
    if os.path.exists("YY丁真合集.txt") :
        os.remove("YY丁真合集.txt")
    for data in new_list :
        with open ("YY丁真合集.txt","a",encoding="utf-8") as writer_file:
            writer_file.write("\n"+data)

if __name__ == "__main__" :
    filter_data()